use std::{array::TryFromSliceError, io};
use thiserror::Error;

#[derive(Error, Debug)]
pub enum ErrorEnum {
    #[error("IO error: {0}")]
    Io(#[from] io::Error),
    #[error("file format error")]
    FileError,
    #[error("invalid magic number")]
    InvalidMagicNumber(String),
    #[error("unsupported version")]
    UnsupportedVersion(u16, u16),
    #[error("convert vec to array error: {0}")]
    ConvertVecToArrayError(String),
    #[error("convert slice to array error: {0}")]
    ConvertSliceToArrayError(#[from] TryFromSliceError),
    #[error("{0}")]
    LengthError(String),
    #[error("{0}")]
    HttpParseError(String),
    #[error("unsupported ether-type protocol {0}")]
    UnsupportedEtherType(u16),
    #[error("unsupported ether-type protocol {0}")]
    UnsupportedIpProtocol(u8),
    #[error("pcap no build index")]
    NoPcapIndexError(usize),
    #[error("read buf length error")]
    ReadBufLengthError(String),
}
